<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>string</title>
</head>
<body>
    <script>
        var str='hello world';
        console.log(str.charCodeAt(4))
        var email='marry@163.com';
        //检测@在email中出现的位置
        console.log(email.indexOf('@'));
        console.log(email.lastIndexOf('.'));
        //截取orl
        console.log(str.slice(7,10));
        console.log(str.slice(1));
        //str.slice(8)
        console.log(str.slice(-3));//不包含最后参数本身；参数为负时，其值为字符串长度+该负数；
        console.log(str.slice(-7,-2));//(4,9)

        console.log(str.substring(-7,5));//(0,5)
        console.log(str.substring(2,-5));//(0,2)
        //substring遇到负数的时候会转换为0

        //substr(start,len) start为负数时，将传入的负值与字符串长度相加；len为负数时，返回空字符串；
        console.log(str.substring(6,5)); //截取值为wor
        console.log(str.substr(-5,4));//(6,4)
    </script>
</body>
</html>